package ascii;

import ME.VPC.M.app.App;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.Iterator;
import java.util.Map;

/*
 * 个人著作权人, 作者 罗瑶光, 浏阳
 * yaoguangluo@outlook.com, 313699483@qq.com, 2080315360@qq.com,
 * （lyg.tin@gmail.com2018年后因G网屏蔽不再使用）
 ** 15116110525-浏阳德塔软件开发有限公司-创始人-法人-总经理-永久非盈利-
 * 430181198505250014, G24402609, EB0581342
 * 204925063, 389418686, F2406501, 0626136
 * 湖南省 浏阳市 集里街道 神仙坳社区 大塘冲路一段
*  208号 阳光家园别墅小区 第十栋别墅 第三层
 * */
//20220701
//20220702 新增一个总分写表
public class WriteASCMap {
    //这个函数用于dnn的全文索引进行txt记录
    public void doWriteASCMap(String stringPath, App app, Map<String, int[][]> subASCmap) {
        Map<String, int[][]> map = subASCmap;
        try {
            File file = new File(stringPath);
            file.createNewFile();
            BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter
                (new FileOutputStream(file), "UTF8"));
            Iterator<String> iterator = map.keySet().iterator();
            while (iterator.hasNext()) {
                //"t_r"
                String temp = iterator.next();
                //添加数据名
                bufferedWriter.write(temp + "<>");
                bufferedWriter.write("\r\n");
                bufferedWriter.flush();
                int[][] maps = map.get(temp);
                for (int j = 0; j < maps[0].length; j++) {
                    bufferedWriter.write(maps[0][j] + "_p");
                    bufferedWriter.write("\r\n");
                }
                for (int j = 0; j < maps[0].length; j++) {
                    bufferedWriter.write(maps[1][j] + "_a");
                    bufferedWriter.write("\r\n");
                }
            }
            bufferedWriter.write("\r\n");
            bufferedWriter.write("end" + "<>");
            bufferedWriter.write("\r\n");
            bufferedWriter.flush();
            bufferedWriter.close();
        } catch (IOException e) {
            app.app_S.hook.hookFrequentException("WriteASCMap出错", System.currentTimeMillis(), e);
        }
    }
}
